package com.itheima.controller;

import com.itheima.common.CommonResult;
import com.itheima.pojo.Records;
import com.itheima.service.SetmealService;
import com.itheima.vo.RecordsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("setmeal")
public class ClientSetmealController {
    @Autowired
    private SetmealService setmealService;
    @GetMapping("/dish/{setmealId}")
    public CommonResult clientGetList(@PathVariable String setmealId){
        RecordsVo recordsVo = setmealService.clientGetList(setmealId);
        if (recordsVo == null) {
            return CommonResult.error("套餐不存在");
        }
        return CommonResult.success(recordsVo);
    }
    @GetMapping("/list")
    public CommonResult clientgetList(@PathVariable String categoryId,
                                      @PathVariable String status){
        List<Records> records = setmealService.clientgetList(categoryId, status);
        if (records == null) {
            return CommonResult.error("套餐不存在");
        }
        return CommonResult.success(records);
    }

}
